package com.ruoyi.web.controller.sis;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.SisPhase;
import com.ruoyi.system.service.SisPhaseService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SisPhase)SIS审批节点表控制层
 *
 * @author makejava
 * @since 2023-08-01 10:18:27
 */
@RestController
@RequestMapping("sisPhase")
public class SisPhaseController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private SisPhaseService sisPhaseService;

    /**
     * 分页查询
     *
     * @param sisPhase 筛选条件
     * @return 查询结果
     */
    @GetMapping
    public TableDataInfo queryByPage(SisPhase sisPhase) {
        startPage();
        List<SisPhase> sisPhases = this.sisPhaseService.queryByPage(sisPhase);
        return getDataTable(sisPhases);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<SisPhase> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.sisPhaseService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param sisPhase 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<SisPhase> add(@RequestBody SisPhase sisPhase) {
        return ResponseEntity.ok(this.sisPhaseService.insert(sisPhase));
    }

    /**
     * 编辑数据
     *
     * @param sisPhase 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<SisPhase> edit(@RequestBody SisPhase sisPhase) {
        return ResponseEntity.ok(this.sisPhaseService.update(sisPhase));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.sisPhaseService.deleteById(id));
    }

}

